import request from "../../utils/request";

export type Service<TData, TParams = any> = (args?: TParams) => Promise<TData>;

const indexApi = {
  index: (params?: { name: string }) =>
    request<API.Response<IndexData>>("/user/index", { method: "GET", params }),
};

export interface IndexData {
  introductory: Introductory[];
  likes: Like[];
  recommended: Recommended[];
  [property: string]: any;
}

export interface Introductory {
  categoryId?: number;
  chaptersCount?: number;
  createdAt?: string;
  id?: number;
  image?: null;
  introductory?: boolean;
  likesCount?: number;
  name?: string;
  recommended?: boolean;
  updatedAt?: string;
  userId?: number;
  [property: string]: any;
}

export interface Like {
  categoryId: number;
  chaptersCount: number;
  createdAt: string;
  id: number;
  image: null;
  introductory: boolean;
  likesCount: number;
  name: string;
  recommended: boolean;
  updatedAt: string;
  userId: number;
  [property: string]: any;
}

export interface Recommended {
  category: Category;
  categoryId: number;
  chaptersCount: number;
  createdAt: string;
  id: number;
  image: null;
  introductory: boolean;
  likesCount: number;
  name: string;
  recommended: boolean;
  updatedAt: string;
  user: User;
  userId: number;
  [property: string]: any;
}

export interface Category {
  id: number;
  name: string;
  [property: string]: any;
}

export interface User {
  id: number;
  username: string;
  [property: string]: any;
}
export default indexApi;
